/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package jp.co.irep.juten.entity;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author toan_nguyen
 */
@Entity
@Table(name = "catalog_product")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CatalogProduct.findAll", query = "SELECT c FROM CatalogProduct c"),
    @NamedQuery(name = "CatalogProduct.findByCatalogId", query = "SELECT c FROM CatalogProduct c WHERE c.catalogProductPK.catalogId = :catalogId"),
    @NamedQuery(name = "CatalogProduct.findByProductId", query = "SELECT c FROM CatalogProduct c WHERE c.catalogProductPK.productId = :productId")})
public class CatalogProduct implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CatalogProductPK catalogProductPK;

    public CatalogProduct() {
    }

    public CatalogProduct(CatalogProductPK catalogProductPK) {
        this.catalogProductPK = catalogProductPK;
    }

    public CatalogProduct(int catalogId, int productId) {
        this.catalogProductPK = new CatalogProductPK(catalogId, productId);
    }

    public CatalogProductPK getCatalogProductPK() {
        return catalogProductPK;
    }

    public void setCatalogProductPK(CatalogProductPK catalogProductPK) {
        this.catalogProductPK = catalogProductPK;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (catalogProductPK != null ? catalogProductPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CatalogProduct)) {
            return false;
        }
        CatalogProduct other = (CatalogProduct) object;
        if ((this.catalogProductPK == null && other.catalogProductPK != null) || (this.catalogProductPK != null && !this.catalogProductPK.equals(other.catalogProductPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "jp.co.irep.tech.juten.jpa.entity.CatalogProduct[ catalogProductPK=" + catalogProductPK + " ]";
    }
    
}
